#pragma once
#include "filter.h"

//////////////////////////////////////////////////////////////////////////
//types map
template<int type>
struct matType;

template<>
struct matType<CV_32SC1>
{
	typedef int type;
};

template<>
struct matType<CV_32FC1>
{
	typedef float type;
};

template<int from, int to>
class ChangeType :
	public Filter
{
public:
	typedef typename matType<from>::type fromType;
	typedef typename matType<to>::type toType;

	ChangeType() : Filter(1,1)
	{}

	virtual ~ChangeType(void){}

	void Process()
	{
		outputs[0] = cv::Mat(inputs[0]->rows, inputs[0]->cols, to);

		for (int i = 0; i < inputs[0]->rows; ++i)
		{
			fromType *in = inputs[0]->ptr<fromType>(i);
			toType *out = outputs[0].ptr<toType>(i);
			for (int j = 0; j < inputs[0]->cols; ++j)
			{
				out[j] = in[j];
			}
		}
	}
};

